<?php

defined('BASEPATH') or die('forbidden');

class ReportCreate_Controller Extends Controller {

    private $inc;

    function _init() {

        check_level(50, segment(0), segment(1), segment(2, 'index'));

        $this->inc = $this->config['inc'];
        
        //$this->db->select_db("crashreport");
    	$this->db->select_db("buglist");	//for test

    	$sql = "SELECT *  FROM eventtype ";
        $this->db->query($sql);
        $eventTypeList = array();	//事件列表
    	while ($n = $this->db->get_array('default')) 
    	{
   			$eventTypeList[$n['eventID']] = $n['eventValue'];
        } 
    	//print_r($eventTypeList);
    }

    function index() {
    	
    	if (is_submit()) 
    	{
            set_time_limit(0);
            sleep(1);
            //print_r($_POST['row']);
            
            $startTime=$_POST['row']['starttime'];
            $endTime = $_POST['row']['endtime'];
            
            //$sql = "delete from analysereport where date(inserttime) between '$startTime' and '$endTime'";
            $sql = " call webCreateReport('$startTime', '$endTime') ";
            //echo "sql = $sql";
            $this->db->execute($sql);
            
            //echo "sql = $sql";
            if(false == $this->db->execute($sql))
            {
            	echo "create fail";
            }else 
            {
            	echo "create success";
            }
            return;
        }
        
        $this->view->display("datastatistics/reportCreate/index");
    }

}

?>